From: Keir Fraser Date: Thu, 20 Aug 2009 15:15:52 +0000 (+0100) Subject: x86: shadow_alloc_p2m_page() should call shadow_prealloc() before shadow_alloc() X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~13443 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=43639f12e85a20f48b77ffe08f137236e0a20131;p=xen.git x86: shadow_alloc_p2m_page() should call shadow_prealloc() before shadow_alloc() shadow_alloc_p2m_page() fails to call shadow_prealloc() before calling shadow_alloc(). In certain conditions, notably when PoD is being exercised, this may cause shadow_alloc() to fail, crashing Xen. Signed-off-by: George Dunlap --- diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index 2b1abb12db..91996624a2 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -1423,7 +1423,6 @@ static void _shadow_prealloc( * to avoid freeing shadows that the caller is currently working on. */ void shadow_prealloc(struct domain *d, u32 type, unsigned int count) { - ASSERT(type != SH_type_p2m_table); return _shadow_prealloc(d, shadow_order(type), count); } @@ -1676,6 +1675,7 @@ sh_alloc_p2m_pages(struct domain *d) < (shadow_min_acceptable_pages(d) + (1 << order)) ) return 0; /* Not enough shadow memory: need to increase it first */ + shadow_prealloc(d, SH_type_p2m_table, 1); pg = mfn_to_page(shadow_alloc(d, SH_type_p2m_table, 0)); d->arch.paging.shadow.p2m_pages += (1 << order); d->arch.paging.shadow.total_pages -= (1 << order);